<template>
  <el-upload
    drag
    action="https://testapi.bscd8.com/upload"
    :data="data"
    :on-success="uploadSuccess"
    :on-error="uploasError"
  >
    <el-icon class="el-icon--upload"><upload-filled /></el-icon>
    <div class="el-upload__text">
      Drop file here or <em>click to upload</em>
    </div>
    <template #tip>
      <div class="el-upload__tip">
        jpg/png files with a size less than 500kb
      </div>
    </template>
  </el-upload>
</template>

<script setup>
defineProps({
  data: Object,
});

const emit = defineEmits(["success"]);
const uploadSuccess = (response, uploadFile, uploadFiles) => {
  console.log(response);
  emit("success", { response, uploadFile, uploadFiles });
};

const uploasError = (error, uploadFile, uploadFiles) => {
  console.log(error);
};
</script>
